package server;

import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;

public class WelcomeClientThread extends Thread
{

	private static ServerSocket serverSocket;
	
	public WelcomeClientThread(final int port) throws IOException
	{
		// abre o socket do servidor
		serverSocket = new ServerSocket(port);
	}
	
	@Override
	public void run()
	{
		while (true)
		{
			try
			{
				// aguarda a conexão de um cliente
				Socket socket = serverSocket.accept();

				// instancia o cliente e coloca na lista de clientes em negociação
				Client client = new Client(socket);
				ServerMain.addNegotiationClient(client);
			}
			catch (IOException e)
			{
				e.printStackTrace();
			}
		}
	}

}
